package com.dabai.iot.core.controller;

import com.dabai.common.core.domain.R;
import com.dabai.common.web.core.BaseController;
import com.dabai.iot.mqtt.api.RemoteMqttService;
import com.dabai.iot.mqtt.model.ServerClient;
import io.swagger.v3.oas.annotations.Operation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 订阅的服务端列表接口
 *
 * @author kev1n
 */
@RestController
@RequestMapping("/server/client")
public class ServerClientController extends BaseController {

    @DubboReference
    private RemoteMqttService remoteMqttService;

    /**
     * 查询消费组对应的订阅服务端列表
     */
    @GetMapping("/list")
    @Operation(summary = "查询消费组对应的订阅服务端列表", description = "传入groupID")
    public R<List<ServerClient>> list(@RequestParam String groupID) {
        return R.ok(remoteMqttService.getServerClientList(groupID));
    }

}
